package com.taobao.client.util;

import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.Constants;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;

public class TradeTable {


	/**
	 * The constants used in this Content Widget.
	 */
	public static interface CwConstants extends Constants {
		String cwFlexTableAddRow();

		String cwFlexTableDescription();

		String cwFlexTableDetails();

		String cwFlexTableName();

		String cwFlexTableRemoveRow();
	}

	/**
	 * An instance of the constants.
	 */
	private static CwConstants constants;
	
	public static FlexTable getTable() {
		final FlexTable flexTable = new FlexTable();

		constants = GWT.create(CwConstants.class);

		FlexCellFormatter cellFormatter = flexTable.getFlexCellFormatter();
		flexTable.addStyleName("cw-FlexTable");
		flexTable.setWidth("800px");
		flexTable.setCellSpacing(5);
		flexTable.setCellPadding(3);

		// Add some text
		cellFormatter.setHorizontalAlignment(0, 1,
				HasHorizontalAlignment.ALIGN_LEFT);
		flexTable.setHTML(1, 0, constants.cwFlexTableDetails());
		// cellFormatter.setColSpan(0, 0, 1);

		flexTable.setText(1, 1, "操作");

		// Add two rows to start

		// Return the panel
		flexTable.ensureDebugId("cwFlexTable");
		return flexTable;
	}

	public static void addRow(FlexTable flexTable, Widget w) {
		int numRows = flexTable.getRowCount();
		flexTable.setWidget(numRows, 0, w);
	}

	public static void addRowButton(FlexTable flexTable, Widget w) {
		int numRows = flexTable.getRowCount();
		flexTable.setWidget(numRows - 1, 1, w);
	}

	
}
